package com.yidu.controller;

import com.yidu.entity.FlFlower;
import com.yidu.entity.FlType;
import com.yidu.service.FlFlowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (FlFlower)表控制层
 *
 * @author liandyao
 * @since 2021-07-29 16:19:47
 */
@RestController
@RequestMapping("/flower")
public class FlFlowerController {
    /**
     * 服务对象
     */
    @Autowired //自动配置
    private FlFlowerService flFlowerService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectOne")
    public FlFlower selectOne(Integer id) {
        return this.flFlowerService.queryById(id);
    }

    @GetMapping("/showList")
    public Map<String ,Object> showList(FlFlower flower){

        //查询并分页
        List<FlFlower> list =  flFlowerService.queryAllByLimit(flower);
        Map<String,Object> map = new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("count",flFlowerService.findCount(flower));
        map.put("data",list);
        return map;
    }
}